package com.sulent.frame.web.controller.test;

import com.sulent.frame.support.entity.R;
import com.sulent.frame.support.utils.ResultUtil;
import com.sulent.frame.web.controller.test.vo.UserGroup;
import com.sulent.frame.web.controller.test.vo.UserVo;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.Size;

/**
 * @ClassName UserVaildController
 * @Description: TODO
 * @Author Submerge.
 * @Since 2025/4/16 19:01
 * @Version 1.0
 */
@RestController
@RequestMapping("/test/user")
public class UserValidController {

    @PostMapping("create")
    public R<String> createUser(@Validated(UserGroup.CreateGroup.class) @RequestBody UserVo userVO) {
        return ResultUtil.success("参数校验成功");
    }

    @PutMapping("update")
    public R<String> updateUser(@Validated(UserGroup.UpdateGroup.class) @RequestBody UserVo userVO) {
        return ResultUtil.success("参数校验成功");
    }

    @GetMapping("getUserById/{id}")
    public R<String> getUserById(@PathVariable @Size(min = 2, max = 5, message = "id长度不符合要求") String id) {
        return ResultUtil.success("参数校验成功");
    }
}
